package com.lvxingli.generateannotation.util;

import com.lvxingli.generateannotation.pojo.PsiFieldWrapper;
import com.lvxingli.generateannotation.pojo.WriteContext;

import static com.lvxingli.generateannotation.util.GenerateUtils.writeAnnotationForce;

/**
 * @author lvxingli
 */
public final class AnnotationTagUtils {

    private AnnotationTagUtils() {
    }


    /**
     * 生成属性的Swagger注解
     *
     * @param psiFieldWrapper 类属性元素
     */
    public static void generateFieldTagAnnotation(WriteContext.PsiFileContext psiFileContext, PsiFieldWrapper psiFieldWrapper, int currentNum) {
        writeAnnotationForce(psiFileContext, ModifierAnnotationUtils.createWrapperTag(currentNum), psiFieldWrapper.getPsiField());
    }

    public static int calcNextGroupBeginNum(int beginNum, int step, int currentNum) {
        return ((currentNum - beginNum) / step + 1) * step + beginNum;
    }

    public static int calcCurrentGroupBeginNum(int beginNum, int step, int currentNum) {
        return ((currentNum - beginNum) / step) * step + beginNum;
    }


}
